/*
 * mpxhelloworld
 *2023happiness
 *work hard 2023
 */
package com.mpx.lawyermanager.dongao.service;

import com.mpx.lawyermanager.dongao.entity.Lawyer;
import com.mpx.lawyermanager.dongao.mapper.LawyerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author mengpeixuan
 * @version 1.0
 */
@Service
public class LawyerServiceImpl implements LawyerService {
    @Autowired
    LawyerMapper lawyerMapper;
    /**
     * 添加律师
     *
     * @param lawyer 律师对象
     * @return 成功返回1.否则0
     */
    @Override
    public int addLawyer(Lawyer lawyer) {
        System.out.println("======" + lawyer.getLawyername());
        return lawyerMapper.insertLawyer(lawyer);
    }

    /**
     * @return 返回律师集合
     */
    @Override
    public List<Lawyer> findLawyer() {
        return lawyerMapper.selectLawyer();
    }

    /**
     * 删除律师信息
     *
     * @param lawyerid 律师编号
     * @return 成功返回1，否则0
     */
    @Override
    public int cancelLawyer(int lawyerid) {
        return lawyerMapper.delLawyer(lawyerid);
    }

    /**
     * 按编号查询律师
     * @param lawyerid 律师编号
     * @return 返回律师对象
     */
    @Override
    public Lawyer findLawyerById(int lawyerid) {
        return lawyerMapper.selectLawyerById(lawyerid);
    }

    /**
     * 修改律师
     *
     * @param lawyer 律师对象
     * @return 成功返回1，否则0
     */
    @Override
    public int modifyLawyer(Lawyer lawyer) {
        return lawyerMapper.updateLawyer(lawyer);
    }
}